 # 每个人有3次助力机会，每接受1次有2豆，4次有8豆(实际是8+2)，8次有15豆(实际是25)，15次有25豆(实际是50)，假设有x人，如何让获取到的豆数最多
import pulp

r = 14

prob = pulp.LpProblem("助力分配问题", pulp.LpMaximize)
# 设置变量
# 1次的人数
x = pulp.LpVariable("x", lowBound=0,cat="Integer")
# 4次的人数
y = pulp.LpVariable("y", lowBound=0,cat="Integer")
# 8次的人数
z = pulp.LpVariable("z", lowBound=0,cat="Integer")
# 15次的人数
a = pulp.LpVariable("a", lowBound=0,cat="Integer")
# 总豆数
total = pulp.LpVariable("total", lowBound=0,cat="Integer")
prob += x + y + z + a == r
prob += x + 4*y + 8*z + 15*a <= 3*r
prob += total <= 2*x + 10*y + 25*z + 50*a
prob += total
prob.solve()
print("最大豆数: " + str(pulp.value(total)))
print("x: " + str(pulp.value(x)))
print("y: " + str(pulp.value(y)))
print("z: " + str(pulp.value(z)))
print("a: " + str(pulp.value(a)))